﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Authentificated.master" AutoEventWireup="true" CodeFile="Shedule.aspx.cs" Inherits="UserManagement_Shedule" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MCPH_Auth" Runat="Server">
    <asp:ObjectDataSource ID="odsDay" runat="server"
        TypeName="PM.BusinessLayer.SheduleController"
        DataObjectTypeName="PM.Entities.Day"
        SelectMethod="SelectDays" />

    <asp:ObjectDataSource ID="odsSpecialities" runat="server"
        TypeName="PM.BusinessLayer.SheduleController"
        DataObjectTypeName="PM.Entities.Speciality"
        SelectMethod="SelectSpecialities" />
    
    <asp:ObjectDataSource ID="odsGroup" runat="server"
        TypeName="PM.BusinessLayer.SheduleController"
        DataObjectTypeName="PM.Entities.Group"
        SelectMethod="SelectGroups" />
        
    <asp:ObjectDataSource ID="odsLessonNumber" runat="server"
        TypeName="PM.BusinessLayer.SheduleController"
        DataObjectTypeName="PM.Entities.LessonNumber"
        SelectMethod="SelectLessonNumber" >
    <SelectParameters>
        <asp:ControlParameter ControlID="ddlDays" Name="dayID" Type="Int32" />
        <asp:ControlParameter ControlID="ddlCourse" Name="course" Type="Int32" />
        <asp:ControlParameter ControlID="ddlGroup" Name="groupID" Type="Int32" />
    </SelectParameters>    
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="odsUser" runat="server"
        TypeName="PM.BusinessLayer.SheduleController"
        DataObjectTypeName="PM.Entities.User"
        SelectMethod="SelectUsers" >
    
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlDays" Name="dayID" Type="Int32" />
            <asp:ControlParameter ControlID="ddlLessonNumber" Name="lessonID" Type="Int32" />
        </SelectParameters>
        
    </asp:ObjectDataSource>
        
    <asp:ObjectDataSource ID="odsSubject" runat="server"
        TypeName="PM.BusinessLayer.SheduleController"
        DataObjectTypeName="PM.Entities.Subject"
        SelectMethod="SelectSubject" />
     
    <asp:ObjectDataSource ID="odsShedule" runat="server"
        TypeName="PM.BusinessLayer.SheduleController"
        DataObjectTypeName="PM.Entities.Shedule"
        EnablePaging="true"
        MaximumRowsParameterName="maxRowCount"
        StartRowIndexParameterName="startIndex"
        SelectCountMethod="GetCount"
        SelectMethod="SelectShedules" 
        DeleteMethod="DeleteSheduleItem"/>
        
    <table style="width:100%; border:1px solid blue;" >
        <tr>
            <th>День</th>
            <th>Курс</th>
            <th>Спеціальність</th>
            <th>Група</th>
            <th>Пара (номер)</th>
            <th>Викладач</th>
            <th>Предмет</th>
            <th>Аудиторія</th>
            <th align="left">Додати</th>
        </tr>
        
        <tr>
            <td>
                <asp:DropDownList ID="ddlDays" runat="server" DataSourceID="odsDay"
                    DataTextField="Name" DataValueField="DayID" AutoPostBack="true" /></td>
                    
            <td>
                <asp:DropDownList ID="ddlCourse" runat="server" AutoPostBack="true" /></td>
                    
            <td>
                <asp:DropDownList ID="ddlSpecialities" runat="server" DataSourceID="odsSpecialities" Width="100px"
                    DataTextField="ShortName" DataValueField="SpecialityID" AutoPostBack="true" /></td>
            
            <td>
                <asp:DropDownList ID="ddlGroup" runat="server" DataSourceID="odsGroup" Width="50px"
                    DataTextField="GroupNumber" DataValueField="GroupID" AutoPostBack="true" 
                    onselectedindexchanged="ddlGroup_SelectedIndexChanged" /></td>
                
            <td>
                <asp:DropDownList ID="ddlLessonNumber" runat="server" 
                    DataSourceID="odsLessonNumber"
                    DataTextField="LessonName" DataValueField="LessonNumberID" 
                    AutoPostBack="true" 
                    onselectedindexchanged="ddlLessonNumber_SelectedIndexChanged" /></td>
                
            <td>
                <asp:DropDownList ID="ddlUser" runat="server" DataSourceID="odsUser"
                    DataTextField="ShortName" DataValueField="UserID" AutoPostBack="true" /></td>
                
            <td>
                <asp:DropDownList ID="ddlSubject" runat="server" DataSourceID="odsSubject"
                    DataTextField="Name" DataValueField="SubjectID" AutoPostBack="true" /></td>
            
            <td>
                <asp:TextBox ID="tbAudience" runat="server" /></td>
                
            <td align="left">
                <asp:Button ID="btnAddSheduleItem" runat="server" 
                    OnClick="btnAddSheduleItem_Click" Text="Додати" /></td>
        </tr>
    </table>
    
    <br />    <br /><br />    <br />
    
    <asp:GridView ID="grvShedule" runat="server" DataSourceID="odsShedule" 
        HeaderStyle-CssClass="SheduleGridView" 
        CssClass="UserGridView"
        AllowPaging="true" PageSize="15" 
        OnRowDeleted="GrvShedule_RowDeleted"
        DataKeyNames="SheduleID"
        AutoGenerateColumns="false">
    <PagerSettings FirstPageText="1" NextPageText="&gt;&gt;" />
    <EmptyDataTemplate>
        Немає жодного запису
    </EmptyDataTemplate>
    <Columns>
        <asp:TemplateField HeaderText="Код">
            <ItemTemplate>
                <%# Eval("SheduleID") %>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Група">
            <ItemTemplate>
                <%# Eval("Group.GroupNumber")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Викладач">
            <ItemTemplate>
                <%#Eval("User.ShortName")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Пара">
            <ItemTemplate>
                <%# Eval("LessonNumber.LessonNumber1")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Курс">
            <ItemTemplate>
                <%# Eval("Course")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="День">
            <ItemTemplate>
                <%# Eval("Day.Name")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Аудиторія">
            <ItemTemplate>
                <%# Eval("NumberAudience")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Предмет">
            <ItemTemplate>
                <%# Eval("Subject.Name")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Спеціальність">
            <ItemTemplate>
                <%# Eval("Speciality.ShortName")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:ImageButton ID="imgBtnDeleteShedule" runat="server" ToolTip="Видалити" CommandName="Delete" ImageUrl="~/Images/remove.jpg" />
            </ItemTemplate>
        </asp:TemplateField>
        
    </Columns>
</asp:GridView>

</asp:Content>